package com.findyou.controller;

import com.findyou.pojo.Headline;
import com.findyou.pojo.vo.PortalVo;
import com.findyou.service.HeadlineService;
import com.findyou.service.TypeService;
import com.findyou.utils.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @Title: ProtalController
 * @Author 贾金博
 * @Package com.findyou.controller
 * @Date 2024/3/7 19:33
 * @description:
 */
@RestController
@RequestMapping("portal")
@CrossOrigin // 跨域
public class PortalController {

    @Autowired
    private TypeService typeService;

    @Autowired
    private HeadlineService headlineService;

    @GetMapping("findAllTypes")
    public Result findAllTypes() {
        Result result = typeService.findAllTypes();
        return result;
    }


    @PostMapping("findNewsPage")
    public Result findNewsPage(@RequestBody PortalVo portalVo) {
      //  System.out.println("portalVo = " + portalVo);
        Result result = headlineService.findNewsPage(portalVo);
        return result;
    }


    /**
     * 记得把浏览量+1
     * 这个还是多表查询
     * @param hid
     * @return
     */
    @PostMapping("showHeadlineDetail")
    public Result showHeadlineDetail(@Param("hid") int hid) {
        Result result = headlineService.showHeadlineDetail(hid);
        return result;
    }
}
